<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>-->
    <!--<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>-->
    <!--<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>-->
    <!--[endif]-->
    <script type="text/javascript" src="../../common/js/public.js"></script>
    <script type="text/javascript" src="../../common/js/publicUtils.js"></script>
    <style>
        .menudiv .layui-input-inline,.buttondiv .layui-input-inline {
            float: left;
            width: 450px !important;
            margin-right: 10px;
        }
        #permissiondiv,.submitdiv{
            display: none;
        }
        .error{
            color: red;
            line-height: 20px;
        }

        .ztreeuldiv {
            height: 100%;
            width: 90%;
            background-color: white;
        }
        .layui-form-label {
            padding: 9px 15px !important;
            width: 50px !important;
        }
        .layui-form-item .layui-inline {
            margin-bottom: 5px;
            margin-right: 0px !important;
        }
    </style>
</head>
<body>
<div class="layui-fluid" id="flowDiv" onload="onLoad()">
    <div class="zTreeBackground right" style="float: left; padding-left:1%;width:100%">
        <table class="layui-hide" id="datatable"></table>
    </div>
    <!--<div class="layui-row layui-col-space15">-->

    <!--<div class="layui-col-md4 treetool" id="flowDiv" onload="onLoad()">-->

    <!--</div>-->
    <!--<div class="layui-col-md8">-->
    <!--<input type="button" value="获取选中项" onclick="getSelectNode()"/>-->
    <!--<input type="button" value="获取check项" onclick="getCheckNode()"/>-->
    <!--<input type="button" value="刷新选中项" onclick="refreshSelectNode()"/>-->
    <!--</div>-->
    <!--</div>-->
</div>
</body>
<SCRIPT type="text/javascript">
    var zTreeObj,zTreeObj_input,zTreeObj_input_button;
    var methodid;//点击当前项数据id
    var form,cols,url,tableObj,table,level=0,treeNodeId=-1,selecNode,count=1;
    var ebs=getUrlParam("ebs");

    layui.use(["form"],function () {
        form = layui.form;
    })
    $(document).ready(function(){
        loadTable();
        //单击行勾选checkbox事件
        $(document).on("click",".layui-table-body table.layui-table tbody tr", function () {
            var index = $(this).attr('data-index');
            var tableBox = $(this).parents('.layui-table-box');
            //存在固定列
            if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length>0) {
                tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
            } else {
                tableDiv = tableBox.find(".layui-table-body.layui-table-main");
            }
            var checkCell = tableDiv.find("tr[data-index=" + index + "]").find("td div.laytable-cell-checkbox div.layui-form-checkbox i");
            if (checkCell.length>0) {
                checkCell.click();
            }
        });

        $(document).on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
            e.stopPropagation();
        });
    });




    function loadTable(){
        var tableurl = publicUrl+'resmethods/selectListByEBSAndPage';
        layui.use(['form','table'], function(){
            form = layui.form;
            table = layui.table;
            tableObj = table.render({
                elem: '#datatable',
                size: 'sm',
                toolbar: '#toolbar',
                even: true, //开启隔行背景
                height: 'full-100',
                method: 'post',
                headers: {"Authorization":getData("Authorization")},
                url: tableurl, //stationId='+window.parent.window.parentId,//8AE7DECA-8E41-4FAB-8B30-9FD1B0B7FA33,78A9E5D8-20FB-4436-BBE8-A25EAC38D056
                where:{
                    "params[ebs]":ebs
                },
                response: {
                    statusCode: 2000
                },
                parseData: function(res){ //res 即为原始返回的数据
                    return formatTableParseData(res);
                },
                request: {
                    pageName: 'pageIndex' //页码的参数名称，默认：page
                    ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
                },
                cols: [[
                    {
                        type:'checkbox',
                        width: "5px",
                    },
                    {
                        type: 'numbers',
                        title: '序号',
                        width: "8%",
                        align: 'center',
                    }, {
                        field: 'code',
                        title: '编码',
                        width: "15%",
                        sort: true,
                        align: 'center',
                    },{
                        field: 'name',
                        title: '名称',
                        sort: true,
                        width: "15%",
                        align: 'center',
                    }, {
                        field: 'classy',
                        title: '分类',
                        sort: true,
                        width: "15%",
                        align: 'center'
                    },{
                        field: 'elementName',
                        title: '构件名称',
                        sort: true,
                        width: "10%",
                        align: 'center'
                    },{
                        field: 'description',
                        title: '描述',
                        width: "15%",
                        align: 'center',
                    }, {
                        field: 'ebs',
                        title: 'EBS编码',
                        width: "15%",
                        align: 'center',
                        templet: function(d) {
                            console.log(d);
                            if (d.ebs.length!=0) {
                                return d.ebs.substring(0,d.ebs.length-1);
                            }
                        }
                    }
                    ]],
                page: true
            });

        });
    }





    /**
     * 打开选中指定节点
     * @param treeobj
     * @param id
     */
    function getAppointNode(treeobj,id){
        if(id){
            var node = treeobj.getNodeByParam("id",id);
            treeobj.selectNode(node,true);//指定选中ID的节点
            //treeobj.expandNode(node, true, false);//指定选中ID节点展开
        }
    }

    /**
     * 刷新指定节点
     */
    function refreshSelectNode(obj,id) {
        var node = obj.getNodeByParam("id",id);
        obj.reAsyncChildNodes(node,"refresh");
    }
    /**
     * 选中某个节点
     */
    function pointNode(obj,id){
        var nodeClick = obj.getNodeByParam("id", id);
        obj.selectNode(nodeClick);//选择点
        obj.setting.callback.onClick(null, id, nodeClick);//调用点击事件
    }

    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return r[2];
        return null;
    }


</script>
</html>